<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        /*
            100 内的整数求和
            1 + 2 + 3 + 4 + 5 + 。。。 + 100
            sum = 1 + 2
            sum + 3
            sum + 4 ...
            1. 遍历 1 - 100
            2. 声明一个变量保存求和
            3. 累加
        */
        let sum = null;
        for (let i = 0; i <= 100; i++) {
            // console.log(i);
            sum = sum + i;
        }
        console.log(sum);


        console.log('----------100 以内的整数倒着遍历求和-------------');


    </script>
</body>

</html>